﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.missions {
    import reprise.ui.*;
    import flash.events.*;
    import flash.display.*;
    import net.wooga.pets.utils.*;

    public class MissionButton extends UIComponent {

        private var _asset:MovieClip;
        private var _icon:MovieClip;
        private var _hook:MovieClip;
        private var _stars:MovieClip;
        private var _arrow:MovieClip;
        private var _arrowTF:DynamicTF;
        private var _id:String;

        override protected function initialize():void{
            super.initialize();
            this._stars = AssetsLibrary.getMovieClip("StarAnimation");
            this._asset = AssetsLibrary.getMovieClip("MissionIcon");
            addChild(this._asset);
            this._hook = AssetsLibrary.getMovieClip("MissionSolvedHook");
            this._hook.x = 10;
            this._arrow = AssetsLibrary.getMovieClip("MissionArrow");
            this._arrow.x = 50;
            this._arrow.y = -30;
            this._arrowTF = new DynamicTF("0xffffff", 16, [Filters.getFilter(Filters.TEXT_OUTLINE_BROWN)]);
            this._arrowTF.x = 280;
            this._arrowTF.y = 14;
            this._arrow.arrow.addChild(this._arrowTF);
            addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
            addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut);
            addEventListener(MouseEvent.MOUSE_DOWN, this.onMouseDown);
            this.show();
        }
        public function set icon(_arg1:String):void{
            Displays.removeChild(this._icon);
            this._icon = AssetsLibrary.getMovieClip(_arg1);
            l(("_icon: " + this._icon));
            if (!this._icon){
                return;
            };
            var _local2:Sprite = new Sprite();
            _local2.addChild(this._icon);
            this._asset.icon.addChild(_local2);
            Displays.correctScaling(_local2, this._icon, 60, 60);
        }
        public function set enabled(_arg1:Boolean):void{
            alpha = (_arg1) ? 1 : 0.3;
            mouseEnabled = (buttonMode = (useHandCursor = _arg1));
        }
        public function set solved(_arg1:Boolean):void{
            if (_arg1){
                addChildAt(this._stars, 0);
                addChild(this._hook);
            } else {
                Displays.removeChild(this._stars);
                Displays.removeChild(this._hook);
            };
        }
        public function init():void{
            super.show();
            this._asset.gotoAndStop("out");
            this.enabled = true;
        }
        override public function show(... _args):void{
            super.show();
            this._asset.gotoAndStop("out");
            this.enabled = true;
        }
        public function showArrow(_arg1:String):void{
            this._arrow.gotoAndPlay(0);
            this._arrowTF.htmlText = _arg1;
            addChild(this._arrow);
            addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
        }
        private function onEnterFrame(_arg1:Event):void{
            if (this._arrow.currentFrame >= this._arrow.framesLoaded){
                removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
                this.hideArrow();
            };
        }
        public function hideArrow():void{
            Displays.removeChild(this._arrow);
        }
        private function onMouseOver(_arg1:MouseEvent):void{
            this._asset.gotoAndStop("over");
        }
        private function onMouseOut(_arg1:MouseEvent):void{
            this._asset.gotoAndStop("out");
        }
        private function onMouseDown(_arg1:MouseEvent):void{
            this._asset.gotoAndPlay("down");
        }
        public function get id():String{
            return (this._id);
        }
        public function set id(_arg1:String):void{
            this._id = _arg1;
        }

    }
}//package net.wooga.pets.views.missions 
